package deibay.server.commands;

import deibay.datamodel.Item;
import deibay.messages.Message;
import deibay.messages.RequestItemDetailsMsg;
import deibay.messages.RequestSellerItemDetailsMsg;
import deibay.messages.SendItemDetailsMsg;
import deibay.messages.SendSellerItemDetailsMsg;
import deibay.server.ServerManager;
import deibay.server.eventargs.SendMessageEventArg;
import deibay.server.events.SendMessageEvent;
import deibay.users.User;

public class RequestSellerItemDetailsCommand extends Command{

	public RequestSellerItemDetailsCommand(User user, Message msg) {
		super(user, msg);
		// TODO Auto-generated constructor stub
	}

	@Override
	public void execute() {
		RequestSellerItemDetailsMsg msg = (RequestSellerItemDetailsMsg)message;
		String itemID = msg.getItem();
		Item item = ServerManager.getInstance().getDataManager().getItem(itemID);
		SendSellerItemDetailsMsg sendMsg = new SendSellerItemDetailsMsg(SendSellerItemDetailsMsg.class.getSimpleName(), item);		
		ServerManager.getInstance().getEventManager().fireEvent(new SendMessageEvent(new SendMessageEventArg(this.user.getId(), sendMsg)));
	}

}
